﻿package com.neriksworkshop.lib.colourLovers.requests 
{
	import com.neriksworkshop.lib.colourLovers.core.AbstractGraphicRequest;
	import com.neriksworkshop.lib.colourLovers.params.Params;
	import com.neriksworkshop.lib.colourLovers.items.Color;
	
	
	/**
	 * ...
	 * @author ...
	 */
	public class ColorRequest extends AbstractGraphicRequest implements IGraphicRequest
	{
		
	
		public function ColorRequest() 
		{
			super(this);
			_baseServiceUrl += "/colors";
		}		

		
		
		public function get hueRange():/*int*/Array { return _params.hueRange; }
		
		public function set hueRange(value:/*int*/Array):void 
		{
			if (value.length != 2 || value[0] > value[1] || value[0] < 0 || value[1] < 0 || value[0] > 359 ||  value[1] > 359) throw Params.ERROR_WRONG_VALUE;
			_params.hueRange = value;
		}
		
		public function get briRange():/*int*/Array { return _params.briRange; }
		
		public function set briRange(value:/*int*/Array):void 
		{
			if (value.length != 2 || value[0] > value[1] || value[0] < 0 || value[1] < 0 || value[0] > 99 ||  value[1] > 99) throw Params.ERROR_WRONG_VALUE;
			_params.briRange = value;
		}		
				
				
		public function get colors():/*Color*/Array { return _items; }
		
		public function get color():Color
		{
			if (_items.length != 1) trace("warning: this request contains more than 1 color, using the first item");
			return _items[0] as Color;
		}
		
		
	}
	
}